package com.tester.zc.test002.threadLocal;

/**
 * @Author zhoucan
 * @Date 2022/12/11
 */
class Resource {

    private Coumputer coumputer;

    synchronized void create() throws Exception{

        if(this.coumputer != null){
            super.wait();
        }
        Thread.sleep(100);
        this.coumputer = new Coumputer();
        System.out.println("生产"+this.coumputer);
        super.notify();
    }

    synchronized void get() throws Exception{

        if(this.coumputer == null){
            super.wait();
        }
        Thread.sleep(100);
        System.out.println("搬走"+this.coumputer);
        this.coumputer = null;
        super.notify();
    }

}
